import React from 'react';
import { GroupColumn } from '@/components/popovercolumn';

const GroupNameCell = ({ data }: { data: any }) => <GroupColumn id={data.id} nameKey="orgName" />;

const cellComponents = { groupNameCell: GroupNameCell };

const columns = [
  {
    fieldName: 'orgName',
    title: tr('组织名称'),
    width: 200,
    render: (text: string, record: any) => <GroupColumn id={record.id} nameKey="orgName" />,
  },
  {
    fieldName: 'orgCode',
    title: tr('组织编码'),
  },
];

const treeColumns = [
  {
    fieldName: 'orgName',
    title: tr('组织名称'),
    width: 200,
    enableRowGroup: true,
    cellRenderer: 'gantGroupCellRenderer',
    cellRendererParams: {
      innerRenderer: 'groupNameCell',
    },
  },
  {
    fieldName: 'orgCode',
    title: tr('组织编码'),
  },
];

const searchUISchema = {
  'ui:col': 24,
  'ui:labelCol': {},
  'ui:wrapperCol': {},
};

const formSchema = { keyWork: { title: tr('组织编码或名称') } };

const nameKeys = {
  selectorEleKey: 'groupSelectorGroupElement',
  modalEleKey: 'groupSelectorModalElement',
  dropDownEleKey: 'groupSelectorDropDownElement',
  popoverEleKey: 'groupSelectorPopoverElement',
};

export { columns, treeColumns, cellComponents, searchUISchema, formSchema, nameKeys };
